Skip to content

Applied Arcjet Protection for rate limiting, spoofed bot detection , … - #3

Merged
Ashutoshmore24 merged 1 commit into
mainfrom
Auth
Aug 9, 2026
Merged

Applied Arcjet Protection for rate limiting, spoofed bot detection , …#3
Ashutoshmore24 merged 1 commit into
mainfrom
Auth

Conversation

@Ashutoshmore24

Copy link
Copy Markdown
Owner

…SQL injection , etc to all auth routes

Copilot AI lite review requested due to automatic review settings August 9, 2026 06:12
@Ashutoshmore24
Ashutoshmore24 merged commit 3e9619d into main Aug 9, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces Arcjet-based security protections for the backend auth endpoints to add automated shielding, bot detection (including spoofing inspection), and rate limiting.

Changes:

  • Adds a shared arcjetProtection Express middleware and applies it to all /api/auth routes.
  • Introduces Arcjet configuration (shield, detectBot, slidingWindow) and wires in new environment variables.
  • Adds Arcjet dependencies to the backend package manifests.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
backend/src/routes/auth.routes.js Applies Arcjet protection middleware to all auth routes.
backend/src/middleware/arcjet.middleware.js Implements the Arcjet protection middleware and denial responses.
backend/src/lib/env.js Adds Arcjet-related environment variable wiring.
backend/src/lib/arcjet.js Adds Arcjet client/rules configuration for shielding, bot detection, and rate limiting.
backend/package.json Adds Arcjet dependencies for runtime usage.
backend/package-lock.json Locks Arcjet dependency tree (includes Node engine requirements).
Files not reviewed (1)
  • backend/package-lock.json: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread backend/package.json
Comment on lines 13 to 14
"type": "module",
"dependencies": {
Comment thread backend/src/lib/arcjet.js
Comment on lines +5 to +29
const aj = arcjet({
key: ENV.ARCJET_KEY,
rules: [
// Shield protects your app from common attacks e.g. SQL injection
shield({ mode: "LIVE" }),
// Create a bot detection rule
detectBot({
mode: "LIVE", // Blocks requests. Use "DRY_RUN" to log only
// Block all bots except the following
allow: [
"CATEGORY:SEARCH_ENGINE", // Google, Bing, etc
// Uncomment to allow these other common bot categories
// See the full list at https://arcjet.com/bot-list
//"CATEGORY:MONITOR", // Uptime monitoring services
//"CATEGORY:PREVIEW", // Link previews e.g. Slack, Discord
],
}),
// Create a token bucket rate limit. Other algorithms are supported.
slidingWindow({
mode: "LIVE", // Blocks requests. Use "DRY_RUN" to log only
max: 100, // Max 100 requests
interval: 60,
}),
],
});
Comment on lines +22 to +25
return res.status(403).json({
error: "Spoofed bot detected",
message: "Malicious bot activity detected.",
});
Comment on lines +29 to +32
} catch (error) {
console.log("Arcjet Protection Error:", error);
next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants